<template>
    <div class="photo">
      <div class="swiper-container a">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item,index) in arrp" :key="index">
            <img :src="item.img" alt="">
          </div>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>
      </div>
    </div>
</template>

<script>
import Swiper from 'swiper'
import 'swiper/dist/css/swiper.css'
export default {
  name: 'Swiper',
  props: ['arrp'],
  methods: {
    so () {
      return new Swiper('.a', {
        // direction: 'vertical', // 垂直切换选项
        loop: true, // 循环模式选项
        autoplay: {
          delay: 2000,
          stopOnLastSlide: false,
          disableOnInteraction: false
        },

        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination'
        }
      })
    }
  },
  watch: {
    arrp (newval) {
      if (newval.length > 0) {
        this.$nextTick(function () {
          this.so()
        })
      }
    }
  }
}
</script>

<style scoped lang="less">
  .photo{
    width: 100%;
    height: 3rem;
    img{
      width: 100%;
      height: 100%;
    }
  }
</style>
